package com.project.dao.implement;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import com.project.dao.SortSingleAccountMapper;
import com.project.utils.SessionFactoryGen;
import com.project.bean.SortSingleAccountByAccount;
import com.project.bean.SortSingleAccountByFund;

public class SortSingleAccountImpl implements SortSingleAccountMapper{
	@Override
	public List<SortSingleAccountByAccount> GetTop20SameAccountCountByPayer(Map val) 
	{
		List<SortSingleAccountByAccount> result = null;
		SqlSession sqlSession = SessionFactoryGen.getSessionFactory().openSession();  
		// TODO Auto-generated method stub
		try
		{
			SortSingleAccountMapper mapper =  sqlSession.getMapper(SortSingleAccountMapper.class);
			result = mapper.GetTop20SameAccountCountByPayer(val);
			sqlSession.commit();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			sqlSession.close();
		}
  
		return result;
	}
	
	@Override
	public List<SortSingleAccountByAccount> GetTop20SameAccountCountByReceiver(Map val) 
	{
		List<SortSingleAccountByAccount> result = null;
		SqlSession sqlSession = SessionFactoryGen.getSessionFactory().openSession();  
		// TODO Auto-generated method stub
		try
		{
			SortSingleAccountMapper mapper =  sqlSession.getMapper(SortSingleAccountMapper.class);
			result = mapper.GetTop20SameAccountCountByReceiver(val);
			sqlSession.commit();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			sqlSession.close();
		}
  
		return result;
	}
	
	@Override
	public List<SortSingleAccountByAccount> GetTop20SameAccountCountByTotal(Map val) 
	{
		List<SortSingleAccountByAccount> result = null;
		SqlSession sqlSession = SessionFactoryGen.getSessionFactory().openSession();  
		// TODO Auto-generated method stub
		try
		{
			SortSingleAccountMapper mapper =  sqlSession.getMapper(SortSingleAccountMapper.class);
			result = mapper.GetTop20SameAccountCountByTotal(val);
			sqlSession.commit();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			sqlSession.close();
		}
  
		return result;
	}
	
	@Override
	public List<SortSingleAccountByFund> GetTop20SameFundCountByPayer(Map val) 
	{
		List<SortSingleAccountByFund> result = null;
		SqlSession sqlSession = SessionFactoryGen.getSessionFactory().openSession();  
		// TODO Auto-generated method stub
		try
		{
			SortSingleAccountMapper mapper =  sqlSession.getMapper(SortSingleAccountMapper.class);
			result = mapper.GetTop20SameFundCountByPayer(val);
			sqlSession.commit();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			sqlSession.close();
		}
  
		return result;
	}
	
	@Override
	public List<SortSingleAccountByFund> GetTop20SameFundCountByReceiver(Map val) 
	{
		List<SortSingleAccountByFund> result = null;
		SqlSession sqlSession = SessionFactoryGen.getSessionFactory().openSession();  
		// TODO Auto-generated method stub
		try
		{
			SortSingleAccountMapper mapper =  sqlSession.getMapper(SortSingleAccountMapper.class);
			result = mapper.GetTop20SameFundCountByReceiver(val);
			sqlSession.commit();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			sqlSession.close();
		}
  
		return result;
	}
	
	@Override
	public List<SortSingleAccountByFund> GetTop20SameFundCountByTotal(Map val) 
	{
		List<SortSingleAccountByFund> result = null;
		SqlSession sqlSession = SessionFactoryGen.getSessionFactory().openSession();  
		// TODO Auto-generated method stub
		try
		{
			SortSingleAccountMapper mapper =  sqlSession.getMapper(SortSingleAccountMapper.class);
			result = mapper.GetTop20SameFundCountByTotal(val);
			sqlSession.commit();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			sqlSession.close();
		}
  
		return result;
	}
}
